<?php


function make_html_header($site_url, $site_title) {

echo <<<HTML_HEADER_END01
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="/blogs/xys/favicon.ico" type="image/x-icon" />
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.de-sci.org/blogs/rss.php" charset="utf-8" />
<title>

HTML_HEADER_END01;


echo "$site_title  </title>";


echo <<<HTML_HEADER_END02

<link rel="stylesheet" href="<?php echo WEBROOT ?>/wp-content/portal/style.css" type="text/css" media="screen" />

<META NAME='KEYWORDS' CONTENT='德赛公园 博客 原新语丝读者网 科学 民主'/>

<META NAME="description" content="《德赛公园》是一个以“科学和民主不过是生活方式”为基调，以宣传科学和民主为基本理念的同人博客网站。网站涉及科学普及、社会民主、医疗健康等诸多话题。 ">

<style type="text/css" media="screen">
</style>
</head>
<body>

HTML_HEADER_END02;


}



function make_html_tailer() {

echo <<<HTML_TAILER_END

</body>
<html>

HTML_TAILER_END;

}



function make_html_top_banner() {



}


function reject_robot() {

if(! preg_match( "/(.*)http(.*)/",$_SERVER["HTTP_USER_AGENT"]) && ! $_GET["test"]==1 )
	echo "not robot";

}




















	// START OF the progarm

	echo "START";



	//require("cache.html"); exit();


	// if(!$_GET["refresh"]){ 
	// 	require("tmp.html"); 
	// 	exit();
	// }

	define('WP_USE_THEMES', true);

	global $more_article;

	$blog='NULL';
	$blogdata='NULL';
	$optiondomain = 'system';
	$_REQUEST['b']='system';

	require('private.php');
	require(CONFIGPATH . 'wp-config.php');
	require_once( ABSPATH . WPINC . '/registration-functions.php');

	require('portal.lib');

	$time_begin= microtime(true);


	get_currentuserinfo();

	$SITE_TITLE = get_settings('site_title');


	if($_GET["CAT_NAME"]){
		$line->cat_name=urldecode($_GET["CAT_NAME"]);
		$line->cat_name=stripslashes($line->cat_name);
		$catalog[0]=$line;
		$record_num=30;	
		$more_article=1;
	}

	// what is this ?
//	get_blocked_in_cat("28120");




	//make_html_header("http://www.de-sci.org", $SITE_TITLE);



	echo $SITE_TITLE;





	//make_html_tailer();


	exit();
?>


<?php 

function make_top_banner() {


	if ($user_identity) { 

		echo "<div id=status>";
		echo "	<div class=description>";
		echo "	logged in as <em>$user_identity</em> ";
		echi " 	<a href=\"login?action=logout\">Log Out</a>";
		echo "	</div>";
		echo "</div>";
	} else { 
		echo "<div id=\"status\" class=\"closed\">&nbsp;</div>";
	}

	echo <<<BANNER01

	<table border=0 align=center width=100% class="mybody">
	<tr>
		<td>
			<div id="page">
				<div id="header" 
					style="background-image:url('./xys/xys-reader-logo.png');
				background-repeat: no-repeat;" align="right">
BANNER01;

	
	if ( isset($_SESSION['slug_error']) ) : 
	<div style="background: #FFEFF7; border: 1px solid #c69; margin: -1em 5% 10px; padding: 0 1em 0 1em; text-align: center; font-size: 15px;" align=center>
	<?php
	echo $_SESSION['slug_error'];
	?>
	</div>
	<?php unset($_SESSION['slug_error']); endif; ?> 

	<div id="sys-login" class="widecolumn">
<?php

	echo '<h3>&nbsp;';
	
	if ($userdata->user_admin){
 	 echo '<a href="system-admin/settings.php">System Settings</a>	&nbsp;';
	}
	
	$myblogs = get_userblogs();
	$sys_admin_user=0;
	if ($myblogs) {
		echo "我的博客: ";
		foreach ($myblogs as $b){
			echo "<a href=\"".$b->home."/admin\">$b->blogname</a>&nbsp;\n";
			if($b->id ==2) $sys_admin_user=1;
		}	
		if($sys_admin_user){
			echo "<a href=\"http://www.de-sci.org/xys/p_cat_show.php?cat_id=28067&admin_mode=on\">[[推荐文章 管理]]</a>&nbsp;\n";
		}
	}else {
		//echo "You do not have permissions on any blogs. Click <em>Register</em> above to make a username and a blog.";
	}
	echo "</h3><br>	";
?>


	<h3>
 	<a href="http://www.de-sci.org">回首页</a>&nbsp;
<?php
	if (!$user_identity) {
		echo ' <a href="./blog_register/">';
		_e('Register');
		echo '</a>&nbsp;<a href="login">'.__('Login').'</a>';
	} else {
		echo '<a href="login?action=logout">'.__('Logout').'</a>';
	}
	echo '&nbsp;<font color=#A1A>||</font>&nbsp;<a href="http://www.de-sci.org/blogs/zhongyantang/help/">帮助</a>';
	echo '-<a href="/blogs/sys_admin/">反馈</a> ';
	echo '&nbsp;<font color=#A1A> </font>&nbsp;<a href="./rss.php">RSS <img width=25 style="border:0px;" src="image/rss.jpg"></a>';
	echo ' </h3>';

	echo "</div>";

?>

</div>
<div id="cat_list">
<ul>
<li>文章分类 :
<?php 
	show_hot(100);
	$all_catalog=get_cat_list();
	$record_num=0;
	$only_cat_name=1;
	$cat_str = show_cat($all_catalog,$record_num,0,$only_cat_name);
	echo $cat_str;
?>
</ul>
</div>


<?php 
if(!$more_article){
?>

<div id="sidebar">

<fieldset id="main-topics">
<legend>=<b> 专题 </b>=
</legend>
<ul>
<?php require("control/link_on_top.txt");?>
</ul>
</fieldset>


<fieldset id="notice-list">
<legend><b>
<a href="http://www.de-sci.org/blogs/sys_admin"> 维护小组公告</a>:
</b>
</legend>
<?php
        $admin_blog="sys_admin";
        $notice_cat="Notice";
        echo get_admin_notice($admin_blog,$notice_cat,4);
?>
</fieldset>

<img align=left src="./xys/momiji_right.jpg" style="padding:14px 14px 15px 5px;">

<?php if (function_exists('get_most_rated') && 0): ?>
<br>
<br>
<fieldset id="highest-rated" >
<legend><b>
   &nbsp;一周最受关注文章
</b>
</legend>

   <ul>
   <?php $blog=0; get_most_rated("post",6); ?>
   </ul>
</fieldset>

<?php endif; ?>



<?php
/*
	$ref_blog_slug="sys_admin";
	$ref_cat_name="PUB";
	echo get_recommended( $ref_blog_slug,$ref_cat_name);
*/
?>

<?php
/*
<div align=center style="background-color: #f7f8fe;  border: 0px dotted #aa6;height:29px;margin:20px 0 0 0;padding:10px 5px 5px 5px">


<script type="text/javascript"><!--
google_ad_client = "pub-3862237077930400";
//180x60，xys-reader portal
google_ad_slot = "8420762184";
google_ad_width = 180;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<br>
本站推荐使用Firefox浏览器
(<a href="http://www.de-sci.org/blogs/sys_admin/2007/12/09/firefox/"> 为什么？</a>)
</div>
*/
?>
<br>
	<h2>&nbsp;最新文章</h2>
<ul class="latest_post">
<?php
	echo get_latest_posts();
?>
</ul>


<img align=left src="./xys/momiji_cmt.jpg" style="padding:14px 14px 15px 5px;">
<h2>&nbsp;最新评论
<font size=2>
( <a href="./comment_list.php">  <?php _e("All"); ?> >> </a> )
</font>

</h2>
<ul class="cmt">
<?php
   $comment_num=15; $str_len=36;
   echo get_all_comment($comment_num,$str_len);
   echo "<br><a href=\"comment_list.php\">".__("All")."...</a>";
?>
</ul>


</div>


<?php 
} //end of first "more"
?>

<div id="read-me">

        <h2 align=left>
<?php 
if($_GET["CAT_NAME"]){
	echo '<a href="./"><br>BACK</a><br>';
}
else{

?>
<br>
<?php
}
?>
	</h2>


<?php
	echo show_site_rec('&nbsp;  &nbsp;<a href="./rss.php"><img style="border: 0px none;margin-bottom:-5px;" src="image/rss.jpg" width="25"></a> &nbsp;编辑推荐 &nbsp;&nbsp; <font size=2><a href="./show_rec.php">全部列表</a></font>&nbsp;&nbsp;',20);
?>

<?php

// Display the hot catalogs.

	//$line->cat_name="Earthquake"; $line->cat_id="10775"; $catalog[0]=$line;

	if(!$more_article){
//	   echo show_hot(6);
	}
?>


<?php
//end of " not more "
?>

<div id="post-list">
<?php
if(!$more_article){
?>
<img align=center src="./xys/momiji.jpg" style="padding:14px 4px 15px 15px;">

<?php
	$mypath="/home/xhyan/www/de-sci.org/blogs";
	$qry="SELECT max(blog_posts.ID) as mydate, count(*) as num
	from blog_posts where post_status=\"publish\"
 	and  NOW()- INTERVAL 9 HOUR  - $wpdb->posts.post_date_gmt  >0
	";
	$re=$wpdb->get_results($qry);
	$status_str = $re[0]->mydate."-".$re[0]->num;

	$fh=fopen($mypath."/blog_status","r");
	$status=fgets($fh,50);
	fclose($fh);


	if($status == $status_str && $_GET["refresh"]!=1 ){
		require("$mypath/cat_backup.html");
		echo "^^";
	}
	else{
		$fh=fopen("$mypath/blog_status","w");
		fputs($fh,$status_str);
		fclose($fh);

		if(!$all_catalog)
		$all_catalog=get_cat_list();

		$record_num=5;
		$cat_str = show_cat($all_catalog,$record_num);
		echo $cat_str;
		$fh=fopen($mypath."/cat_backup.html","w");
		fputs($fh,$cat_str);
		fclose($fh);
	}

} else{
    echo show_cat($catalog);
}


?>
</div>
<img width=820 align=center src="./xys/momiji_btm.jpg" style="padding:4px 14px 10px 5px;">



<div style="clear:both;"></div>

<?php

//judge wheather the visitor is a robot.
}

?>
<div id="blog-list">
<fieldset><legend><b><font size=4> All Blogs</font></b></legend>
<ul>
<?php
   echo get_all_blogs();
?>	
</ul>
</fieldset>
<br clear="both"/>
</div>

<div align=center>
( <a href="/blogs/friends.php">Your Friends On DE-SCI.ORG</a> )
</div>

<div id="footer">
&nbsp;|<a href="http://groups.google.com/group/xys-blog/web/%E8%AF%BB%E8%80%85%E7%BD%91%E5%8D%9A%E5%AE%A2%E7%AD%B9%E5%BB%BA%E8%AE%A1%E5%88%92%E4%B9%A6?hl=zh-CN">关于本站</a>  | 
<a href="http://groups.google.com/group/xys-blog/web/%E8%8D%89%E6%A1%88%EF%BC%9A%E5%8D%9A%E5%AE%A2%E7%BD%91%E7%AB%99%E6%9C%8D%E5%8A%A1%E6%9D%A1%E6%AC%BE?hl=zh-CN">服务条款</a> | 
<a href="http://groups.google.com/group/xys-blog/web/%E7%AE%A1%E7%90%86%E5%A7%94%E5%91%98%E4%BC%9A?hl=zh-CN">维护小组</a>-<a href="/blogs/sys_admin/">Blog</a> |
<a href="http://code.google.com/p/lyceum-xys-reader/"> Our Project@Google Code</a>|
<a href="http://www.de-sci.org/blogs/portal.php?refresh=1"> Refresh Site </a>|
<a href="/blogs/sys_admin/">反馈</a> |

&nbsp; Powered by LYCEUM and Wordpress<br>
</div>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2718547-1";
urchinTracker();
</script>

</td>
</tr>
</table>

<?php
?>	

</body>
</html>

<?php

$time_end=microtime(true);
$time_used= - $time_begin + $time_end;
echo "\n<!-- $time_begin - > $time_end = $time_used  -->\n";

?>
<!-- DOWNLOAD_OVER -->
